/**
 * 
 */
package teehee.UI;

import teehee.homepage.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

/**
 * @author Shubham
 *
 */
public class MainPage extends Activity{
	
	 public void onCreate(Bundle savedInstanceState) 
	    {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.main);
	        
	        Button go2 = (Button) findViewById(R.id.button2); //links  to add new wod/excercise
	        go2.setOnClickListener(new OnClickListener() 
	        {
	        	public void onClick(View v) 
	        	{
	        		Intent addNewWOD = new Intent(MainPage.this, AddNewTabs.class);
	        		startActivity(addNewWOD);
	        	}
	        });
	        
	        //links to search page
	        Button go5 = (Button) findViewById(R.id.button5); 
	        go5.setOnClickListener(new OnClickListener()  
	        {
	        	public void onClick(View v) 
	        	{
	        		try{
	        		Intent searchp = new Intent(MainPage.this, SearchPage.class);
	        		startActivity(searchp);
	        		}
	        		catch(Exception e)
	        		{
	        			e.printStackTrace();
	        		}
	        		//setContentView(R.layout.search);  
	        	}
	        });
	        
	        
	        /*
	         *Button for health page.
	         */
	        Button go4 = (Button) findViewById(R.id.button4); 

	        go4.setOnClickListener(new OnClickListener()  
	        {
	        	public void onClick(View v) 
	        	{

	        		Intent healthp = new Intent( MainPage.this, Health.class);
	        		startActivity(healthp);
	        	}
	        });
	        
	        Button go1 = (Button) findViewById(R.id.button1); //links  to add new wod/excercise
	        go1.setOnClickListener(new OnClickListener() 
	        {
	        	public void onClick(View v) 
	        	{
	        		Intent wp = new Intent(MainPage.this, WodPage.class);
	        		startActivity(wp);
	        	}
	        });
	        
	        /*
	         * History page link
	         */
	        Button go3 = (Button) findViewById(R.id.button3); //links  to add new wod/excercise
	        go3.setOnClickListener(new OnClickListener() 
	        {
	        	public void onClick(View v) 
	        	{
	        		Intent historyP = new Intent(MainPage.this, HistoryPage.class);
	        		startActivity(historyP);
	        	}
	        });
	        
	    }

	 @Override //goes to search page
	    public boolean onKeyDown(int keyCode, KeyEvent event) 
	    {
	        if ((keyCode == KeyEvent.KEYCODE_SEARCH)) //replace "MENU" with "SEARCH" to use the search button
	        { 
	        	//setContentView(R.layout.search); //xml file to display, found in res/layout
	        	Intent homep = new Intent(MainPage.this, SearchPage.class); //XXX.this is the current page. YYY.class is the destination page.
	    		startActivity(homep);
	            return true;
	        }
	        return super.onKeyDown(keyCode, event);    
	    } 
}
